'use strict';

const Service = require('egg').Service;

class UserService extends Service {
    //排重
    async selectUser(username) {
        return await this.app.mysql.query('select * from userlist where username=?',[username])
    }
    //注册
    async registry(username,pwd){
        await this.app.mysql.query('insert into userlist (username,password) values (?,?)',[username,pwd])
    }
    //登录
    async login(username,pwd){
        return await this.app.mysql.query('select * from userlist where username=? and password=?',[username,pwd])
    }

    //获取菜单
    async list(role_id){
        return await this.app.mysql.query(`select * from reslist where power like '%${role_id}%'`)
    }
}

module.exports = UserService;
